<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="ui" uri="http://com.am.tag2" %>
<%@ include file="../common.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>My JSP 'userList.jsp' starting page</title>
     <style type="text/css">
    	.linkActive{color:#ff9900;text-decoration:none;font-weight:bold;}
		.linkNoActive{color:#3399ff;}
    </style>
    <script type="text/javascript" src="${path}/js/public/grid.js"></script>
    <link rel="stylesheet" href="${path}/css/showtable.css" type="text/css"></link>
    <!-- 插入打印控件 -->
      <OBJECT  ID="jatoolsPrinter" CLASSID="CLSID:B43D3361-D075-4BE2-87FE-057188254255"
                  codebase="jatoolsPrinter.cab#version=8,6,0,0"></OBJECT>  
  	<script type="text/javascript">
  	
	  	//0--学生 1-教职工 2-退休 3-离休  4-其他
		var viewArray = ["0","1","2","3","4"];
	  	
		function addCss(id){
    		$.each( viewArray, function(n, i){
    			if(i == id){
    				$("#"+i).find("span").removeClass();
    				$("#"+i).find("span").addClass("linkActive");
    			}else {
    				$("#"+i).find("span").removeClass();
    				$("#"+i).find("span").addClass("linkNoActive");
    			}
    		});
    	}
		
		$().ready(function(){
	    	
    		addCss("0");
    		doChangeView("0");
    	});
  		
  		
  		
  		function doQuery()
  		{
  			resetGrid(mygrid,"queryForm",{"type":currentView});
  		}
  		
  		var currentView = "0";
  		function doChangeView(flag)
    	{
    		addCss(flag);
    		currentView = flag;
  			resetGrid(mygrid,null,{"type":flag});
    	}
  		
  		
  		function statusRender(value)
  		{
  			if(value == "0"){
  				return "不在册";
  			}else{
  				return "在册";
  			}
  		}
  		
  		function typeRender(value)
  		{
  			if(value == "0"){
  				return "学生";
  			}else if(value == "1"){
  				return "教职工";
  			}else if(value == "2"){
  				return "退休";
  			}else if(value == "3"){
  				return "离休";
  			}else{
  				return "其他";
  			}
  		}
  		
  		
  		function overdueRender(value)
  		{
  			if(value == "1"){
  				return "<img src='${path}/images/6.png' width='15px' height='15px'/>过期";
  			}else{
  				return "<img src='${path}/images/1.png' width='15px' height='15px'/>未过期";
  			}
  		}
  		
  		function doReset()
  		{
  			$("#name").val("");
  			$("#sex").val("");
  			$("#campus").val("");
  			$("#id_card").val("");
  			$("#card_num").val("");
  			$("#class").val("");
  			$("#anamnesis").val("");
  			$("#num").val("");
  		}
  		
  		function addMakeCards(){
  			if(!isSelectOne(mygrid))
  			{
  				alert("请选择一条记录进行查看");
  				return;
  			}
  			
  			var record = mygrid.getSelectedRecords()[0];
  		}
  		
  		/* function doPrint(str){
  			alert(str);
  		} */
  		
  		function doChoose(){
			/* if(!isSelectOne(mygrid))
			{
				alert("请选择一条记录进行添加");
				return;
			} */
			var records = mygrid.getSelectedRecords();
			addRow(records);
		}
		
		var arr = new Array();
  		var i = 0; 
		function addRow(records){
			for(var k=0;k<records.length;k++){
				var record = records[k];
				if(checkRecord(record)){
					var innerHTML = "<tr onmouseover='changeStyle(this,true)' onmouseout='changeStyle(this,false)' id='"+record['id']+"' style='text-align:center'>";
					innerHTML += "<td style='display:none;'>"+record['type']+"</td>";
					innerHTML += "<td>"+record['name']+"</td>";
					innerHTML += "<td>"+record['sex']+"</td>";
					innerHTML += "<td>"+record['birthday']+"</td>";
					if(record['card_num']==null){
						innerHTML += "<td></td>";
					}else{
						innerHTML += "<td>"+record['card_num']+"</td>";
					}
					innerHTML += "<td align='center'><a href='javascript:void(0)' onclick='delRow("+record['id']+");'>删除</a></td>";
					innerHTML += "</tr>";
					$(".showtable").append(innerHTML);
					arr[i] = record['id'];
					i++;
				}
			}
			//chooseDrug.mygrid.reload(); //刷新表格
  		}
  		
  		function checkRecord(record){
  			for(var j in arr){
				if(arr[j] == record['id']){
					//alert(record['name'] + "制卡已添加，只保留一个。");
					return false;
				};
			};
			return true;
  		}
  		
  		function delRow(idIndex){
  			//$(this).parent().parent().remove();
  			$("tr[id='" + idIndex + "']").remove();//删除当前行
			for(var j in arr){
				if(arr[j] == idIndex){
					arr.splice(j,1);
					return;
				};
			};
  		}
  		
  		function changeStyle(obj,flag)
		{
			flag ? $(obj).css("background-color","#ffff99") : $(obj).css("background-color","");
		}
		
		function doPrintAll(){
			var trArr = $("#printTable tr");
			for(var i=1;i<trArr.length;i++){
				if($("#printTable tr:eq("+i+") td:eq(0)").text() == "0"){
   	  				$("#type").val("学生");
   	  			}else if($("#printTable tr:eq("+i+") td:eq(0)").text() == "1"){
   	  				$("#type").val("教职工");
   	  			}else if($("#printTable tr:eq("+i+") td:eq(0)").text() == "2"){
   	  				$("#type").val("退休");
   	  			}else if($("#printTable tr:eq("+i+") td:eq(0)").text() == "3"){
   	  				$("#type").val("离休");
   	  			}else{
   	  				$("#type").val("其他");
   	  			}
   	  			$("#name1").val($("#printTable tr:eq("+i+") td:eq(1)").text());
   	  			$("#sex1").val($("#printTable tr:eq("+i+") td:eq(2)").text());
   	  			$("#birthday").val($("#printTable tr:eq("+i+") td:eq(3)").text());
   	  			$("#card_num1").val($("#printTable tr:eq("+i+") td:eq(4)").text());
   	  			$("#personTable").hide();
   	  			$("#allMessage").hide();
   	  			doPrint('打印...');
			}
		}
		
		function doPrint(how) { 
	   			 var myDoc = {
	   			 	settings:{paperName:'a4'},   // 选择a4纸张进行打印
	   			 	//settings:{orientation:2},   // 选择横向打印,1为纵向，2为横向
	   			 	//settings:{topMargin:100,
			                  //leftMargin:100,
			                  //bottomMargin:100,
			                  //rightMargin:100},   // 设置上下左距页边距为10毫米，注意，单位是 1/10毫米
			        //settings:{printer:'OKi5530'},//设置到打印机 'OKi5530'
			        
	        		documents: document,
	        		copyrights: '杰创软件拥有版权  www.jatools.com'
	   			 }; 
		   		 if (how == '打印预览...') {
		        	 jatoolsPrinter.printPreview(myDoc);} // 打印预览
		    	 else if (how == '打印...') {
		         	jatoolsPrinter.print(myDoc, false); // 打印前弹出打印设置对话框
		         	}
		    	else
		         	jatoolsPrinter.print(myDoc, false); // 不弹出对话框打印
			}
  	</script>
  </head>
  <body>
  	<table id="personTable" cellSpacing="0" cellPadding="0" style="width:100%;height:415px;" border="0">
  		<tr>
			<td class="windowTitle">人员管理  &gt; 人员信息管理&gt;批量制卡</td>
		</tr>
  		<tr id="">
			<td style="height:35px;width:100%" class="windowHead">	
				<form id="queryForm">
					<table cellSpacing="0" cellPadding="0" width="100%" height="100%" border="0" >
						<tr>
							<td width="800" height="20" valign="middle">	
								<img alt="view" src="${path}/images/menu/view.png" height="18px" width="20px" align="top"></img>
								<font style="font-weight:bold;">&nbsp;视图：</font>&nbsp;&nbsp;
								<a href="javascript:doChangeView('0')" id="0"><span>学生</span></a>&nbsp;&nbsp;&nbsp;
								<a href="javascript:doChangeView('1')" id="1"><span>教职工</span></a>&nbsp;&nbsp;&nbsp;
								<a href="javascript:doChangeView('2')" id="2"><span>退休</span></a>&nbsp;&nbsp;&nbsp;
								<a href="javascript:doChangeView('3')" id="3"><span>离休</span></a>&nbsp;&nbsp;&nbsp;
								<a href="javascript:doChangeView('4')" id="4"><span>其他</span></a>&nbsp;&nbsp;
							</td>
						</tr>
						<tr>
							<td>
								<table cellpadding="0" cellspacing="0" style="border: 0">
									<tr height="25px">
										<td width="60px" align="right">姓名：</td>
										<td width="145px" align="left"><input name="search_CONTAIN_name" id="name" type="text" class="textbox" style="width:145px;" /></td>
										<td width="80px" align="right">性别：</td>
										<td width="145px" align="left">
											<select name="search_EQ_sex" id="sex" style="width:145px;margin-left: 3px">
												<option value ="">-- 请选择 --</option>
									  			<option value ="男">男</option>
									  			<option value ="女">女</option>
											</select>
										</td>
										<td width="80px" align="right">所在校区：</td>
										<td width="145px" align="left">
											<select name="search_EQ_campus" id="campus" style="width:145px;margin-left: 3px">
												<option value="">--请选择--</option>
												<option value="校本部">校本部</option>
												<option value="白云校区">白云校区</option>
												<option value="北校区">北校区</option>
												<option value="西校区">西校区</option>
											</select>
										</td>
										<td width="60px" align="right"><ui:Button type="query" onclick="doQuery()">查询</ui:Button></td>
									</tr>
									<tr height="25px">
										<td width="60px" align="right">证件号：</td>
										<td width="145px" align="left"><input name="search_CONTAIN_id_card" id="id_card" type="text" class="textbox" style="width:145px;" /></td>
										<td width="80px" align="right">医疗卡号：</td>
										<td width="145px" align="left"><input name="search_CONTAIN_card_num" id="card_num" type="text" class="textbox" style="width:145px;" /></td>
										<td width="100px" align="right">学号/工资卡号：</td>
										<td width="145px" align="left">
											<input name="search_CONTAIN_num" id="num" type="text" class="textbox" style="width:145px;" />
										</td>
										<td width="60px" align="right"><ui:Button onclick="doReset()"><img src="${path}/images/menu/reset.png" />重置</ui:Button></td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td>
								<ui:Button type="save" onclick="doChoose()">添加</ui:Button>
							</td>
						</tr>
					</table>
				</form>
				<br/>
				<a style="text-decoration: none;"></a>
			</td>
		</tr>
		<tr id="">
			<td style="width:100%;height:100%;overflow:hidden"  class="windowBody">
		    	<div id="mess_box" style="width:100%;height:100%;overflow:hidden">
			    	<ui:Grid id="mygrid" css="width:100%;height:100%"
			    			onCellClicked="selectedMultiRow"
				    		 dataProvider="com.system.provider.PersonListProvider:getData">
				    	<ui:GridField name="id" header="ID" isChecked="true"  align="center"/>
				    	<ui:GridField name="name" header="姓名" align="center" width="17%"/>
				    	<ui:GridField name="sex" header="性别"  align="center" width="7%"/>
				    	<ui:GridField name="id_card" header="证件号" align="center" width="15%"/>
				    	<ui:GridField name="card_num" header="医疗卡号" align="center" width="16%"/>
				    	<ui:GridField name="is_overdue" header="医疗卡是否过期" align="center" width="10%" render="overdueRender"/>
				    	<ui:GridField name="campus" header="所在校区" align="center" width="10%"/>
				    	<ui:GridField name="birthday" header="出生日期" align="center" width="14%"/>
				    	<ui:GridField name="type" header="类型" render="typeRender" align="center" width="8%"/>
			    	</ui:Grid>
		    	</div>
		    </td>
		</tr>
  	</table>
	<div id="allMessage" style="float:left;padding:10px">
	   	<table class="showtable" width="100%" id="printTable">
			<tr>
				<th style="display:none">类型</th>
				<th width="20%">姓名</th>
				<th width="20%">性别</th>
				<th width="25%">出生年月</th>
				<th width="20%">卡号</th>
				<th width="15%">操作</th>
			</tr>
		</table>
	</div>
	<div id="page1" style="text-align:center;padding-top:20px;">
   			<fieldset style="width :75%; height: 20%;" >
			    <span style="font-size:30">广东技术师范学院</span><br/>
			    <span style="font-size:30">公费医疗卡</span>
			    <form id="winForm" name="winForm">
				    <table style="margin-top:15px">
				   		<tr>
				   			<td align="right">姓名</td>
				   			<td><input type="text" id="name1" style="width:120px;BORDER-RIGHT: medium none;BORDER-TOP: medium none;BORDER-LEFT: medium none;BORDER-BOTTOM:black 1px solid;text-align:center" ></td>
				   			<td>性别</td>
				   			<td><input type="text" id="sex1" style="width:50px;BORDER-RIGHT: medium none;BORDER-TOP: medium none;BORDER-LEFT: medium none;BORDER-BOTTOM:black 1px solid;text-align:center" ></td>
				   		</tr>
				   		
				   		<tr>
				   			<td>出生年月</td>
				   			<td><input type="text" id="birthday" style="width:120px;BORDER-RIGHT: medium none;BORDER-TOP: medium none;BORDER-LEFT: medium none;BORDER-BOTTOM:black 1px solid;text-align:center" ></td>
				   			<td>类型</td>
				   			<td><input type="text" id="type" style=";width:50px;BORDER-RIGHT: medium none;BORDER-TOP: medium none;BORDER-LEFT: medium none;BORDER-BOTTOM:black 1px solid;text-align:center" ></td>
				   		</tr>
				   		
				   		<tr>
				   			<td align="right">卡号</td>
				   			<td colspan="3"><input type="text" id="card_num1" style="width:300px;BORDER-RIGHT: medium none;BORDER-TOP: medium none;BORDER-LEFT: medium none;BORDER-BOTTOM:black 1px solid;text-align:center" ></td>
				   		</tr>
				   		
				   		<tr>
				   			<td>所在单位</td>
				   			<td colspan="3"><input type="text" " id="departments" style="width:300px;BORDER-RIGHT: medium none;BORDER-TOP: medium none;BORDER-LEFT: medium none;BORDER-BOTTOM:black 1px solid;text-align:center" ></td>
				   		</tr>
				   	</table>
			   	</form>
		   		<input type="text" name="medicalCard" id="medicalCard" style="width:300px;BORDER-RIGHT: medium none;BORDER-TOP: medium none;BORDER-LEFT: medium none;BORDER-BOTTOM:medium none;" >
		   </fieldset>	
		</div>
  </body>
</html>
